import React, { useRef, useState } from 'react'

export default function App() {
  let [name, setName] = useState('张三')
  let [password, setPassword] = useState(123)
  const save = (e) => {
    e.preventDefault()
    console.log(nameRef.current.value, passwordRef.current.value)
  }
  let nameRef = useRef()
  let passwordRef = useRef()
  return (
    <div>
      <form onSubmit={save}>
        <label>
          姓名:
          <input type="text" defaultValue={name} ref={nameRef} />
        </label>
        <br />
        <label>
          密码:
          <input type="password" defaultValue={password} ref={passwordRef} />
        </label>
        <br />
        <button>提交</button>
      </form>
    </div>
  )
}
